//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for NetworkFirewall
public struct NetworkFirewallErrorType: AWSErrorType {
    enum Code: String {
        case insufficientCapacityException = "InsufficientCapacityException"
        case internalServerError = "InternalServerError"
        case invalidOperationException = "InvalidOperationException"
        case invalidRequestException = "InvalidRequestException"
        case invalidResourcePolicyException = "InvalidResourcePolicyException"
        case invalidTokenException = "InvalidTokenException"
        case limitExceededException = "LimitExceededException"
        case logDestinationPermissionException = "LogDestinationPermissionException"
        case resourceNotFoundException = "ResourceNotFoundException"
        case resourceOwnerCheckException = "ResourceOwnerCheckException"
        case throttlingException = "ThrottlingException"
        case unsupportedOperationException = "UnsupportedOperationException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize NetworkFirewall
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// AWS doesn't currently have enough available capacity to fulfill your request. Try your request later.
    public static var insufficientCapacityException: Self { .init(.insufficientCapacityException) }
    /// Your request is valid, but Network Firewall couldn’t perform the operation because of a system problem. Retry your request.
    public static var internalServerError: Self { .init(.internalServerError) }
    /// The operation failed because it's not valid. For example, you might have tried to delete a rule group or firewall policy that's in use.
    public static var invalidOperationException: Self { .init(.invalidOperationException) }
    /// The operation failed because of a problem with your request. Examples include:    You specified an unsupported parameter name or value.   You tried to update a property with a value that isn't among the available types.   Your request references an ARN that is malformed, or corresponds to a resource that isn't valid in the context of the request.
    public static var invalidRequestException: Self { .init(.invalidRequestException) }
    public static var invalidResourcePolicyException: Self { .init(.invalidResourcePolicyException) }
    /// The token you provided is stale or isn't valid for the operation.
    public static var invalidTokenException: Self { .init(.invalidTokenException) }
    /// Unable to perform the operation because doing so would violate a limit setting.
    public static var limitExceededException: Self { .init(.limitExceededException) }
    /// Unable to send logs to a configured logging destination.
    public static var logDestinationPermissionException: Self { .init(.logDestinationPermissionException) }
    /// Unable to locate a resource using the parameters that you provided.
    public static var resourceNotFoundException: Self { .init(.resourceNotFoundException) }
    public static var resourceOwnerCheckException: Self { .init(.resourceOwnerCheckException) }
    /// Unable to process the request due to throttling limitations.
    public static var throttlingException: Self { .init(.throttlingException) }
    /// The operation you requested isn't supported by Network Firewall.
    public static var unsupportedOperationException: Self { .init(.unsupportedOperationException) }
}

extension NetworkFirewallErrorType: Equatable {
    public static func == (lhs: NetworkFirewallErrorType, rhs: NetworkFirewallErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension NetworkFirewallErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
